/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

/**
 * <p>Project: javase - Format1
 * <p>Powered by webrx On 2021-11-22 15:41:26
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Format1 {
    public static void main(String[] args) {
        String name = "李四";
        int age = 8;
        System.out.printf("姓名：%s，年龄：%02d岁。%n", name, age);
        System.out.printf("姓名：" + name + "，年龄：" + age + "岁。%n");

        //true - 14 - ff - 09 - a
        System.out.printf("%b - %o - %x - %02x - %c%n", true, 12, 255, 9, 97);

        //% 10.000
        System.out.printf("%% %.3f%n", 10f);

        //100.124
        System.out.printf("%.3f%n", 100.124248d);

        //1,024,240.12
        System.out.printf("%,.2f", 1024240.124248d);
        System.out.println();

        //左对齐
        System.out.printf("%-5d%n", 15);
        //右对齐
        System.out.printf("%5d%n", 15);
        //右对齐，长度不够补0
        System.out.printf("%05d%n", 15);
    }
}
